package com.young.mylib.db;

import android.content.Context;
import android.util.Log;

/**
 * Created by Young on 2018/3/29.
 */

public class DatabaseUtils {
    private final static String TAG = "DatabaseUtils";
    private static SqliteUtils mHelper;
    public static String dbFile = "SmartKanban.db";

    private DatabaseUtils() {
    }

    /**
     * 一般来说这里的initHelper放到application中去初始化
     * 当然也可以在项目运行阶段初始化
     */
    public static void initHelper(Context context, String name) {
        Log.i(TAG, "初始化: " + name);
        if (mHelper == null) {
            mHelper = new SqliteUtils(context, name);
        }
    }

    public static SqliteUtils getHelper() {
        if (mHelper == null) {
            Log.i(TAG,"db helper is null");
            new RuntimeException("SqliteUtils is null,No init it");
        }
        return mHelper;
    }
}
